<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
                'id' => 'news-form',
                'enableAjaxValidation' => false,
            ));
    ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>


    <table>
        <tr>
            <td><?php echo $form->labelEx($model, 'news_title'); ?></td>
            <td>
                <?php echo $form->textField($model, 'news_title', array('size' => 60, 'maxlength' => 255)); ?>
                <?php echo $form->error($model, 'news_title'); ?>
            </td>
        </tr>
        <tr>
            <td><?php echo $form->labelEx($model, 'news_detail'); ?></td>
            <td>
                <?php echo $form->textField($model, 'news_detail', array('size' => 60, 'maxlength' => 255)); ?>
                <?php echo $form->error($model, 'news_detail'); ?>
            </td>
        </tr>
        <tr>
            <td><?php echo $form->labelEx($model, 'news_content'); ?></td>
            <td>
                <?php echo $form->textArea($model, 'news_content', array('rows' => 6, 'cols' => 50)); ?>
                <?php echo $form->error($model, 'news_content'); ?>
            </td>
        </tr>
        <tr>
            <td>News Image</td>
                <td> 
                <input type="hidden" id="news_pic_path" value="<?php echo $model->news_pic_path; ?>" name="News[news_pic_path]">
                    <?php
                        if($model->news_pic_path){
                            ?>
                                <img onclick="image_upload('news_pic_path', 'preview_brand_image_path');" class="image" id="preview_brand_image_path" alt="" src="<?php echo Yii::app()->request->baseUrl;?><?php echo $model->news_pic_path;?> "/>
                            <?php
                        }else{
                           ?>
                                <img onclick="image_upload('news_pic_path', 'preview_brand_image_path');" class="image" id="preview_brand_image_path" alt="" src="<?php echo Yii::app()->request->baseUrl;?>/images/filemanager/no_image-100x100.jpg"/>
                            <?php 
                        }
    
                    ?>
                </td>
            </td>
        </tr>
    </table>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>     

    <?php $this->endWidget(); ?>

</div><!-- form -->

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/ui/jquery-ui-1.8.9.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.9.custom.css" />
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/ui/external/jquery.bgiframe-2.1.2.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/jstree/jquery.tree.min.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/javascript/jquery/ajaxupload.js"></script>
   
<script type="text/javascript"><!--
function image_upload(field, preview) {
    $('#dialog').remove();
    $('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index/field/' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
    $('#dialog').dialog({
    title: 'Image Manager',
    close: function (event, ui) {
    if ($('#' + field).attr('value')) {
    $.ajax({
    url: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/image',
    type: 'POST',
    data: 'image=' + encodeURIComponent($('#' + field).attr('value')),
    dataType: 'text',
    success: function(data) {
    $('#' + preview).replaceWith('<img src="' + data + '" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />');
    }
    });
    }
    },
    bgiframe: false,
    width: 800,
    height: 400,
    resizable: false,
    modal: false
});
};
//--></script>

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/javascript/ckeditor/ckeditor.js"></script> 
<script type="text/javascript"><!--
CKEDITOR.replace('News_news_content', {
    filebrowserBrowseUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
    filebrowserImageBrowseUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
    filebrowserFlashBrowseUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
    filebrowserUploadUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
    filebrowserImageUploadUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
    filebrowserFlashUploadUrl: '<?php echo Yii::app()->request->baseUrl;?>/index.php/Filemanager/index',
});
//--></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/javascript/ckeditor/config.js?t=B49E5BQ"></script>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/javascript/ckeditor/skins/kama/editor.css?t=B49E5BQ">
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/javascript/ckeditor/lang/en.js?t=B49E5BQ"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/javascript/ckeditor/plugins/styles/styles/default.js?t=B49E5BQ"></script> 